<%--
  Created by IntelliJ IDEA.
  User: 16128
  Date: 2020/8/10
  Time: 16:56
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <form action="account/logon" method="post">
        username:<input name="username"><span id="usernameInfo"></span><br>
        password:<input name="password"><br>
        <select name="status">
            <option value="admin">admin</option>
            <option value="user">user</option>
            <option value="doctor">doctor</option>
        </select>
        <input type="submit" value="submit">
    </form>
    <a href="index.jsp">登录</a>

    <script src="jquery-3.5.1.min.js"></script>
    <script>
        $("input[name='username']").blur(function () {
            $.ajax({
                url: "account/checkUsername",
                type: "POST",
                data: $("input[name='username']").val(),
                contentType:"application/json",
                success: function (res) {
                    if(res) {
                        $("#usernameInfo").text("用户名已存在")
                    }
                    else {
                        $("#usernameInfo").text("用户名可以使用")
                    }
                }
            })
        })
    </script>
</body>
</html>
